﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace Chemix.UI
{
    [RequireComponent(typeof(Text))]
    public class Framerate : MonoBehaviour
    {

        // Use this for initialization
        void Start()
        {
            m_NextTime = Time.time + 1;
            text = GetComponent<Text>();
            text.text = "...";
        }

        // Update is called once per frame
        void Update()
        {
            m_FrameCount++;
            if (Time.time > m_NextTime)
            {
                m_NextTime += 1f;
                text.text = m_FrameCount.ToString();
                m_FrameCount = 0;
            }
        }

        Text text;

        int m_FrameCount = 0;
        float m_NextTime = 0;
    }
}